#include <jni.h>
#include "lrc.h"

char getLRC(char* src,int len){
	char response = src[0];
	for(int i = 1; i < len ; i++)
		response ^= src[i];
	return response;
}

JNIEXPORT jbyte JNICALL
				Java_cd_algorithm_Lrc_getLrc(JNIEnv *env, jclass type, jbyteArray datas_, jint index, jint length) {
    jbyte ret;
	jbyte *datas = (*env)->GetByteArrayElements(env,datas_, NULL);

    ret = getLRC(datas+index,length);

	(*env)->ReleaseByteArrayElements(env,datas_, datas, 0);
    return ret;
}

